import request from '@/utils/request'
import qs from 'qs'

export function add(data) {
  return request({
    url: 'product/add',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'product/delete',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'product/update',
    method: 'put',
    data
  })
}

export function getOne(id) {
  return request({
    url: '/product/' + id,
    method: 'get',
    data: id
  })
}

export function getAll(params) {
  return request({
    url: '/product/all',
    method: 'get',
    params: params
  })
}

export function allProduct(params) {
  return request({
    url: '/product/allProduct',
    method: 'get',
    params: params
  })
}

export function pageList(params) {
  return request({
    url: '/product/pageList',
    method: 'get',
    params
  })
}

export function getProduct(nameCn) {
  return request({
    url: '/product/page',
    method: 'get',
    params: nameCn
  })
}

export function onOffShelf(data) {
  return request({
    url: '/product/onOffShelf',
    method: 'put',
    params: data
  })
}

export function updatePackType(data) {
  return request({
    url: '/product/updatePackType',
    method: 'put',
    params: data
  })
}

export function audit(data) {
  return request({
    url: '/product/audit',
    method: 'put',
    params: data
  })
}

export function updateSetDelivery(data) {
  return request({
    url: '/product/updateSetDelivery',
    method: 'put',
    params: data
  })
}

export function exportProduct(data) {
  return request({
    url: '/product/exportProduct' + '?' + qs.stringify(data, { indices: false }),
    method: 'GET',
    responseType: 'blob'
  })
}

export default {
  add,
  edit,
  del,
  getOne,
  getAll,
  getProduct,
  allProduct,
  onOffShelf,
  updatePackType,
  audit,
  exportProduct,
  pageList,
  updateSetDelivery
}
